package com.car.tx;

import com.car.common.model.VipRecord;
import com.jfinal.aop.Before;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.tx.Tx;
import com.utils.Toolkit;

public class OrderService {
	
	public static OrderService one = new OrderService();
	
	@Before(Tx.class)
	public boolean record(VipRecord one, String pay_type) {
		if (one.getStatus() != 2 ) {
			return false;
		}
		if (one.getOrderType() == 1) {
			
//			Db.update("update users set vip_end_time =  " +  (System.currentTimeMillis()/1000L + one.getTime()*86400) +", hot_val = hot_val + "+ one.getZsHot() +" where id = "+ one.getUserId() );
			Db.update("update vip_record set status = 1 ,buy_type = '"  + pay_type +"' where id = " + one.getId());
			return true;
		} else if (one.getOrderType() == 2) {
			Db.update("update users set hot_val = hot_val + "+ one.getHot() +" where id = "+ one.getUserId() );
			Db.update("update vip_record set status = 1 ,buy_type = '"  + pay_type +"' where id = " + one.getId());
			return true;
		} 
		return false;
	}
}
